package com.ericsson.enap.modules.ebmLog.service.impl.vgc;

import com.ericsson.common.pojo.FTPInfoVO;
import com.ericsson.common.util.SFtpCarrierUtilNew;
import com.ericsson.enap.modules.ebmLog.entity.vgc.VgcNetEntity;
import com.ericsson.enap.modules.ebmLog.service.vgc.VgcEbmDownloadProcess;
import org.slf4j.Logger;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@Component
@Scope("prototype")
public class VgcEbmDownloadProcessAMFImpl implements VgcEbmDownloadProcess {
    @Override
    public String downloadFile(VgcNetEntity vgcNetEntity, String storePath, Logger log,boolean down,String ebmlogtime) {
        FTPInfoVO ftpInfo = new FTPInfoVO();
        ftpInfo.setHost(vgcNetEntity.getIp4());
        ftpInfo.setPort(21);
        ftpInfo.setUserName(vgcNetEntity.getUsername());
        ftpInfo.setPassword(vgcNetEntity.getPassword());
        ftpInfo.setPath(vgcNetEntity.getDownloadPath());
        ftpInfo.setNetElementID(vgcNetEntity.getId());
        ftpInfo.setDownloadebmlogtime(ebmlogtime);
        SFtpCarrierUtilNew sFtpCarrierUtil = new SFtpCarrierUtilNew(ftpInfo, log);
        String downloadTime = sFtpCarrierUtil.batchDownLoadFileSCP(ftpInfo.getPath(), storePath, down, vgcNetEntity.getName(),60);
        return downloadTime;
    }
}
